// 隐私策略弹窗
import { handlePrivacy } from '@/services/login';
import { useRequest } from 'ahooks';
import { Modal } from 'antd';
import { useEffect } from 'react';
import { useIntl } from 'umi';
type Props = {
  visible: boolean;
  handleCancel: () => void;
  title?: string;
};
const PrivacyModal: React.FC<Props> = ({ visible, handleCancel, title }) => {
  const intl = useIntl();
  const { data, run } = useRequest(handlePrivacy, { manual: true });
  const { content } = data?.data || {};
  useEffect(() => {
    if (visible) run();
  }, [visible, run]);
  return (
    <Modal
      zIndex={9999}
      footer={false}
      width={900}
      onCancel={handleCancel}
      open={visible}
      destroyOnClose
    >
      <div className="private_modal_title">
        {title || intl.formatMessage({ id: 'home.private_title' })}
      </div>
      <div className="private_modal_content" dangerouslySetInnerHTML={{ __html: content || '' }} />
    </Modal>
  );
};

export default PrivacyModal;
